<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改银行种类')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bank-edit" th:object="${bank}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">银行名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">编码：</label>
				<div class="col-sm-8">
					<input id="code" name="code" th:field="*{code}" class="form-control" type="text" required>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "basedata/bank";
		$("#form-bank-edit").validate({
			rules:{
                name:{
					remote: {
                        url:prefix + "/checkBankNameUnique",
						type: "post",
						dataType: "json",
						data: {
                            "id":function () {
								return $("input[name='id']").val();
                            },
                            "name":function () {
								return $.common.trim($("#name").val());
                            }
						},
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
					}
				},
			},
            messages: {
                "name": {
                    remote: "银行名称已经存在"
                }
            },
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
                var data = [];
                var name = $("input[id='name']").val();
                var code = $("input[id='code']").val();
                var id = $("input[id='id']").val();
                data.push({"name": "name", "value": name});
                data.push({"name": "code", "value": code});
                data.push({"name": "id", "value": id});
                $.operate.save(prefix + "/edit", data);
	        }
	    }
	</script>
</body>
</html>
